import time

from selenium.webdriver.common.by import By

from common.Utils import BlogDriver


class BLogDetail:
    def __init__(self):
        self.url = "http://8.137.19.140:9090/blog_detail.html?blogId=84567"
        self.driver = BlogDriver.driver
        self.driver.get(self.url)

    #登录状态下博客详情页的测试
    def DetailTestByLogin(self):
            #检查标题
            print(self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div > div.title").text)
            #检查时间
            print(self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div > div.date").text)
            #检查内容
            print(self.driver.find_element(By.CSS_SELECTOR, "#detail").text)
            #屏幕截图
            #time.sleep(3)
            # alter_ = self.driver.switch_to.alert
            # '''获取弹窗的文本内容'''
            # actual = alter_.text
            # # 关闭弹窗
            # alter_.accept()
            BlogDriver.getScreenShot()